package com.harmontronics.hanma.paas.paas.controller;

import java.util.Arrays;
import java.util.List;

import cn.hutool.core.bean.BeanUtil;
import com.harmontronics.hanma.paas.paas.common.ResponseEntity;
import com.harmontronics.hanma.paas.paas.common.PageBase;
import cn.hutool.core.convert.Convert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import com.harmontronics.hanma.paas.paas.service.HmUserReportAppService;
import com.harmontronics.hanma.paas.paas.dto.iam.output.HmUserReportResult;
import com.harmontronics.hanma.paas.paas.dto.iam.input.HmUserReportCreateInput;
import com.harmontronics.hanma.paas.paas.dto.iam.input.HmUserReportUpdateInput;
import com.harmontronics.hanma.paas.paas.domain.iam.entity.HmUserReport;
import com.harmontronics.hanma.paas.paas.utils.ParamUtils;

import javax.validation.Valid;


/**
 * 用户-报表
 *
 * @author paas-generator
 * @email paas-generator@harmontronics.com
 * @date 2021-04-29 16:09:57
 */
@RestController
@RequestMapping("/api/hmuserreport")
@Api(tags = {"用户-报表"})
public class HmUserReportController {
    @Autowired
    private HmUserReportAppService hmUserReportappService;

    /**
     * 列表
     */
    @GetMapping("/info")
    @ApiOperation("详情")
    public ResponseEntity<HmUserReportResult> info() {
        HmUserReport hmUserReport = hmUserReportappService.getInfo();

        return ResponseEntity.ok(BeanUtil.toBean(hmUserReport,HmUserReportResult.class));
    }


    /**
     * 保存
     */
    @PostMapping()
    @ApiOperation("保存")
    public ResponseEntity<String> save(@Valid @RequestBody HmUserReportCreateInput hmUserReportInput, BindingResult bindingResult) {
        ParamUtils.valid(bindingResult);
        HmUserReport hmUserReport =BeanUtil.toBean(hmUserReportInput,HmUserReport. class);
            hmUserReportappService.save(hmUserReport);

        return ResponseEntity.ok();
    }

    /**
     * 修改
     */
    @PutMapping
    @ApiOperation("修改")
    public ResponseEntity<String> update(@Valid @RequestBody HmUserReportUpdateInput hmUserReportInput, BindingResult bindingResult) {
        ParamUtils.valid(bindingResult);
        HmUserReport hmUserReport =BeanUtil.toBean(hmUserReportInput,HmUserReport. class);
            hmUserReportappService.update(hmUserReport);
        return ResponseEntity.ok();
    }


}
